package com.sunwayworld.basemodule.rm.equipment.instrumentacqresult.service.impl;

import com.sunwayworld.basemodule.rm.equipment.instrumentacqresult.bean.LimsInstrumentAcqResultBean;
import com.sunwayworld.basemodule.rm.equipment.instrumentacqresult.dao.LimsInstrumentAcqResultDao;
import com.sunwayworld.basemodule.rm.equipment.instrumentacqresult.service.LimsInstrumentAcqResultService;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@GikamBean
public class LimsInstrumentAcqResultServiceImpl implements LimsInstrumentAcqResultService {

    @Autowired
    private LimsInstrumentAcqResultDao limsInstrumentAcqResultDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsInstrumentAcqResultDao getDao() {
        return limsInstrumentAcqResultDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsInstrumentAcqResultBean limsInstrumentAcqResult = jsonWrapper.parseUnique(LimsInstrumentAcqResultBean.class);
        limsInstrumentAcqResult.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsInstrumentAcqResult);
        return limsInstrumentAcqResult.getId();
    }

}
